import QtQuick
import QtQuick.Window
import QtQuick3D.Effects 6.2
import Qt5Compat.GraphicalEffects
import QtQuick.Controls
import MyTcpSocket 1.0

Window {
    id:root
    width: Screen.desktopAvailableWidth
    height: Screen.desktopAvailableHeight
//    width: 1080
//    height: 720
    visible: true

    property url bacgroundUrl: "qrc:/img/img/background1.jpg"

    //黑色背景模式
//        property color btnColor: "#2e3034"
//        property color cardColor: "#C0191b1d"
//        property color textColor: "white"
//        property color btnColorPressed: "transparent"
//        property color backgroundColor: "#e6e6e6"

    //白色背景模式
    property color btnColor: "#fdfdfd"
    property color cardColor: "#c0e6e6e6"
    property color textColor: "black"
    property color btnColorPressed: "transparent"
    property color backgroundColor: "#e6e6e6"

    MyTcpSocket{
        id:tcpSocket
    }

    Image {//背景图片
        id: background
        anchors.fill: parent
        source: bacgroundUrl
    }

    StackView{
        id:rootStackView
        anchors.fill: parent
        initialItem: mainPage
    }
    Component{
        id:mainPage
        Item{
            anchors.fill: background
            //    上下两段式结构
            Rectangle{
                id: topBar
                width: parent.width
                height: 100
                anchors.top: parent.top
                color: "transparent"
                Loader {
                    source: "TopBtn.qml"
                    anchors.fill: parent // 将加载的内容填充到此矩形中
                }
            }
            Rectangle{
                id: contentItem
                width: parent.width
                height: parent.height - topBar.height
                anchors.top: topBar.bottom
                color: "transparent"
//                StackView{
//                    id: mainStackView
//                    anchors.fill: parent
//                    initialItem: myHome
//                }

                Loader {
                    id: contentLoader
                    source: "MyHome.qml"
                    anchors.fill: parent
//                    asynchronous: true
                }
            }
        }
    }

    Popup {
        id: hintPopup
        width: 400
        height: 400
        modal: true
        contentItem: Rectangle {
            width: 400
            height: 400
            color: "white"

            Text {
                id:hintPopupText
                text: "功能待开发"
                anchors.centerIn: parent
            }
            Button{
                anchors.bottom: hintPopup.bottom
                text:"关闭"
                onClicked: hintPopup.close()
            }
        }
        closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
        anchors.centerIn: parent

        background: Rectangle {
            color: "white" // 设置为透明
            border.color: textColor
            border.width: 1
            radius: 20
        }
    }

    Device{
        id:devicePage
    }
    Scene{
        id:scenePage
    }
    Camera{
        id:cameraPage
    }
//    MyHome{
//        id:myHome
//    }
//    Room{
//        id:room
//    }
}
